using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Daniel.Core.Models.Mapping
{
    public class CheckoutAttributeValueMap : EntityTypeConfiguration<CheckoutAttributeValue>
    {
        public CheckoutAttributeValueMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Name)
                .IsRequired()
                .HasMaxLength(400);

            this.Property(t => t.ColorSquaresRgb)
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("CheckoutAttributeValue");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.CheckoutAttributeId).HasColumnName("CheckoutAttributeId");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.ColorSquaresRgb).HasColumnName("ColorSquaresRgb");
            this.Property(t => t.PriceAdjustment).HasColumnName("PriceAdjustment");
            this.Property(t => t.WeightAdjustment).HasColumnName("WeightAdjustment");
            this.Property(t => t.IsPreSelected).HasColumnName("IsPreSelected");
            this.Property(t => t.DisplayOrder).HasColumnName("DisplayOrder");

            // Relationships
            this.HasRequired(t => t.CheckoutAttribute)
                .WithMany(t => t.CheckoutAttributeValues)
                .HasForeignKey(d => d.CheckoutAttributeId);

        }
    }
}
